﻿using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApp58.Models;

namespace WpfApp58
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ObservableCollection<Product> products = new ObservableCollection<Product>();

            for (int i = 0; i < 10; i++)
            {
                products.Add(new Product()
                {
                    Id = i,
                    Name = "Product" + i,
                    Price = 1 + i,
                    Description = "Description" + i
                });
            }

            LbProducts.ItemsSource = products;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (sender is Button btn)
            {
                if (btn.Tag is Product product)
                {
                    string name = product.Name;
                }
            }
        }
    }
}